﻿<%@ Page ValidateRequest="false" Title="" Language="C#" MasterPageFile="~/admin/Site1.Master" AutoEventWireup="true" CodeBehind="Products.aspx.cs" Inherits="gamexpert.admin.Products" Theme="Admin" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<script>
    var doc_base_url = "<%= Request.Url.AbsolutePath%>";
</script>
<script type="text/javascript" src="../js/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript" src="../js/tinymce_product.js"></script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<h2>Products</h2>
<div class="content">
    <asp:MultiView ID="MultiView1" runat="server">
        <asp:View ID="View1" runat="server">
            <div><p>List of all products</p></div>
            <div class="dropdown">
                <label >Category:</label>
                <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" 
                    onselectedindexchanged="DropDownList1_SelectedIndexChanged">
                    <asp:ListItem>Games</asp:ListItem>
                    <asp:ListItem>Accessories</asp:ListItem>
                    <asp:ListItem Selected="True">All</asp:ListItem>
                </asp:DropDownList>
                 | 
                <asp:Button ID="Button1" runat="server" Text="Add New Product" 
                    onclick="Button1_Click" />
            </div>
      
            <div >
                 <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
                     AllowSorting="True" AutoGenerateColumns="False" BackColor="White" 
                     BorderColor="#DEDFDE" BorderStyle="None" BorderWidth="1px" CellPadding="4" 
                     DataKeyNames="id" DataSourceID="SqlDataSource1" ForeColor="Black" 
                     GridLines="Vertical" onrowdeleted="GridView1_RowDeleted" 
                     onselectedindexchanged="GridView1_SelectedIndexChanged1" PageSize="40">
                     <RowStyle BackColor="#F7F7DE" />
                     <Columns>
                         <asp:CommandField ShowDeleteButton="True" />
                         <asp:TemplateField ShowHeader="False">
                             <ItemTemplate>
                                 <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" 
                                     CommandName="Select" Text="Edit"></asp:LinkButton>
                             </ItemTemplate>
                         </asp:TemplateField>
                         <asp:BoundField DataField="id" HeaderText="Product ID" InsertVisible="False" 
                             ReadOnly="True" SortExpression="id" />
                         <asp:BoundField DataField="title" HeaderText="Title" SortExpression="title" />
                         <asp:BoundField DataField="price" HeaderText="Price(S$)" 
                             SortExpression="price" />
                         <asp:BoundField DataField="shippingcost" HeaderText="Shipping Cost(S$)" 
                             SortExpression="shippingcost" />
                         <asp:BoundField DataField="category" HeaderText="Category" 
                             SortExpression="category" />
                         <asp:BoundField DataField="createdon" HeaderText="Created Date" 
                             SortExpression="createdon" />
                         <asp:BoundField DataField="download" HeaderText="Download file name" 
                             SortExpression="download" />
                     </Columns>
                     <FooterStyle BackColor="#CCCC99" />
                     <PagerStyle BackColor="#F7F7DE" ForeColor="Black" HorizontalAlign="Right" />
                     <SelectedRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" />
                     <HeaderStyle BackColor="#6B696B" Font-Bold="True" ForeColor="White" />
                     <AlternatingRowStyle BackColor="White" />
                 </asp:GridView>
                 <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                     ConnectionString="<%$ ConnectionStrings:gamexpertConnectionString %>" 
                     DeleteCommand="DELETE FROM [my_product] WHERE [id] = @id" 
                     InsertCommand="INSERT INTO [my_product] ([title], [shortdescription], [description], [price], [shippingcost], [image], [category], [createdon], [publisher], [developer], [platform], [published], [keywords], [download]) VALUES (@title, @shortdescription, @description, @price, @shippingcost, @image, @category, @createdon, @publisher, @developer, @platform, @published, @keywords, @download)" 
                     SelectCommand="SELECT * FROM [my_product]" 
                     UpdateCommand="UPDATE [my_product] SET [title] = @title, [shortdescription] = @shortdescription, [description] = @description, [price] = @price, [shippingcost] = @shippingcost, [image] = @image, [category] = @category, [createdon] = @createdon, [publisher] = @publisher, [developer] = @developer, [platform] = @platform, [published] = @published, [keywords] = @keywords, [download] = @download WHERE [id] = @id">
                     <DeleteParameters>
                         <asp:Parameter Name="id" Type="Int32" />
                     </DeleteParameters>
                     <UpdateParameters>
                         <asp:Parameter Name="title" Type="String" />
                         <asp:Parameter Name="shortdescription" Type="String" />
                         <asp:Parameter Name="description" Type="String" />
                         <asp:Parameter Name="price" Type="Decimal" />
                         <asp:Parameter Name="shippingcost" Type="Decimal" />
                         <asp:Parameter Name="image" Type="String" />
                         <asp:Parameter Name="category" Type="String" />
                         <asp:Parameter Name="createdon" Type="DateTime" />
                         <asp:Parameter Name="publisher" Type="String" />
                         <asp:Parameter Name="developer" Type="String" />
                         <asp:Parameter Name="platform" Type="String" />
                         <asp:Parameter Name="published" Type="Boolean" />
                         <asp:Parameter Name="keywords" Type="String" />
                         <asp:Parameter Name="download" Type="String" />
                         <asp:Parameter Name="id" Type="Int32" />
                     </UpdateParameters>
                     <InsertParameters>
                         <asp:Parameter Name="title" Type="String" />
                         <asp:Parameter Name="shortdescription" Type="String" />
                         <asp:Parameter Name="description" Type="String" />
                         <asp:Parameter Name="price" Type="Decimal" />
                         <asp:Parameter Name="shippingcost" Type="Decimal" />
                         <asp:Parameter Name="image" Type="String" />
                         <asp:Parameter Name="category" Type="String" />
                         <asp:Parameter Name="createdon" Type="DateTime" />
                         <asp:Parameter Name="publisher" Type="String" />
                         <asp:Parameter Name="developer" Type="String" />
                         <asp:Parameter Name="platform" Type="String" />
                         <asp:Parameter Name="published" Type="Boolean" />
                         <asp:Parameter Name="keywords" Type="String" />
                         <asp:Parameter Name="download" Type="String" />
                     </InsertParameters>
                 </asp:SqlDataSource>
            
            </div>
        </asp:View>
        <asp:View ID="View2" runat="server">
        <p>Please fill in all the required information and click submit to add a new product.</p>
            <asp:Panel ID="Panel1" runat="server" CssClass="pform" DefaultButton="btnSubmit">
            <fieldset>
                <legend>Add/Edit Product Information</legend>
                <asp:ValidationSummary ID="ValidationSummary1" runat="server" ValidationGroup="a" />
             <table>
                <tr>
                    <td>Product ID:</td>
                    <td><asp:Label ID="lblid" runat="server" Text=""></asp:Label></td>
                </tr>
                <tr>
                    <td>Title:</td>
                    <td>
                        <asp:TextBox ID="txttitle" runat="server" CssClass="textbox"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
                            ControlToValidate="txttitle" ErrorMessage="Please fill in title." 
                            ValidationGroup="a">*</asp:RequiredFieldValidator>
                     </td>
                </tr>
                <tr>
                    <td>Short Description:</td>
                    <td><asp:TextBox ID="txtshortdescription" runat="server" CssClass="textbox"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" 
                            ControlToValidate="txtshortdescription" 
                            ErrorMessage="Please fill in short description." ValidationGroup="a">*</asp:RequiredFieldValidator>
                    </td>
                </tr>
                <tr>
                    <td>Description:</td>
                    <td><asp:TextBox ID="txtdescription" runat="server" Rows="10" TextMode="MultiLine" 
                            CssClass="textbox"></asp:TextBox></td>
                </tr>
                <tr>
                    <td>Price:S$</td>
                    <td><asp:TextBox ID="txtprice" runat="server" CssClass="textbox"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" 
                            ControlToValidate="txtprice" ErrorMessage="Please fill in price." 
                            ValidationGroup="a">*</asp:RequiredFieldValidator>
                        <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" 
                            ControlToValidate="txtprice" ErrorMessage="Please fill in valid price." 
                            ValidationExpression="^[0-9]+(\.[0-9]+)?$" ValidationGroup="a">*</asp:RegularExpressionValidator>
                    </td>
                </tr>
                <tr>
                    <td>Shipping Cost:S$</td>
                    <td><asp:TextBox ID="txtshippingcost" runat="server" CssClass="textbox"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" 
                            ControlToValidate="txtshippingcost" 
                            ErrorMessage="Please fill in shipping cost." ValidationGroup="a">*</asp:RequiredFieldValidator>
                        <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" 
                            ControlToValidate="txtshippingcost" 
                            ErrorMessage="Please fill in valid shipping cost." 
                            ValidationExpression="^[0-9]+(\.[0-9]+)?$" ValidationGroup="a">*</asp:RegularExpressionValidator>
                    </td>
                </tr>
                <tr>
                    <td>Image:</td>
                    <td>
                        <asp:Image ID="Image1"  runat="server" /><br />
                        <asp:FileUpload ID="FileUpload1" runat="server" Width="217px" />
                        <asp:RegularExpressionValidator ID="RegularExpressionValidator3" runat="server" 
                            ControlToValidate="FileUpload1" 
                            ErrorMessage="Please select correct image file type(jpg,gif,tiff,bmp..)." 
                            ValidationExpression="([0-9a-zA-Z :\\-_!@$%^&amp;*()])+(.jpg|.JPG|.jpeg|.JPEG|.bmp|.BMP|.gif|.GIF|.psd|.PSD)$" 
                            ValidationGroup="a">*</asp:RegularExpressionValidator>
                    </td>
                </tr>
                <tr>
                    <td>Category:</td>
                    <td>
                        <asp:DropDownList ID="DropDownList2" runat="server" AutoPostBack="True" 
                            onselectedindexchanged="DropDownList2_SelectedIndexChanged">
                            <asp:ListItem>Games</asp:ListItem>
                            <asp:ListItem>Accessories</asp:ListItem>
                        </asp:DropDownList>
                    </td>
                </tr>
                <tr>
                    <td>Publisher:</td>
                    <td><asp:TextBox ID="txtpublisher" runat="server" CssClass="textbox"></asp:TextBox></td>
                </tr>
                <tr>
                    <td>Developer:</td>
                    <td><asp:TextBox ID="txtdeveloper" runat="server" CssClass="textbox"></asp:TextBox></td>
                </tr>
                <tr>
                    <td>Platform:</td>
                    <td><asp:TextBox ID="txtplatform" runat="server" CssClass="textbox"></asp:TextBox></td>
                </tr>
                <tr>
                    <td>Keywords:</td>
                    <td><asp:TextBox ID="txtkeywords" runat="server" CssClass="textbox"></asp:TextBox></td>
                </tr>
                <tr>
                    <td><asp:Label ID="lbldownloadcaption" runat="server" Text="Download:"></asp:Label></td>
                    
                    <td>
                        <asp:Label ID="lbldownload" runat="server" Text="Label"></asp:Label><br />
                        <asp:FileUpload ID="FileUpload2" runat="server" /></td>
                </tr>
               
                
                <tr>
                    <td colspan="2">
                        <asp:Button ID="btnSubmit" runat="server" Text="Submit" ValidationGroup="a" onclick="btnSubmit_Click" 
                            /> 
                        <asp:Button ID="btnCancel" runat="server" Text="Cancel" onclick="btnCancel_Click" 
                            />
                    </td>
                </tr>
                
                
                
            </table>
            </fieldset>
            </asp:Panel>
        
           
        
        </asp:View>
        <asp:View ID="View3" runat="server">
        
        </asp:View>
    </asp:MultiView>
</div>
</asp:Content>
